#include <iostream>
#include <vector>
using namespace std;

class Solution {
public:
    vector<int> singleNumber(vector<int>& nums) {
        int total = 0;
        for (auto e : nums)
            total ^= e;
        int tag = 0;
        for (int i = 0; i < 32; ++i) {
            if ((total >> i) & 1 == 1) {
                tag = i;
                break;
            }
        }
        int n1 = 0;
        for (auto e : nums) {
            if ((e >> tag) & 1 == 1) {
                n1 ^= e;
            }
        }
        int n2 = n1 ^ total;
        vector<int> ret{ n1, n2 };
        return ret;
    }
};